package main

import "fmt"

//常量,定义了常量之后不能修改，在程序运行期间不会改变的量
const pi = 3.1415926

//批量声明常量
const (
	StatusOk = 200
	NotFound = 404
)

//批量声明常量，如果某一行声明后没有赋值，默认就和上一行一致
const (
	n1 = 100
	n2
	n3
)

//iota
const (
	a1 = iota //0
	a2        //1
	a3        //2
	a4        //3
)

//下划线  _  跳过某些值
const (
	b1 = iota //0
	b2        //1
	_         //2
	b3        //3
)

//混用   因为定义了一个常量c2=100，下面c3和c4没有被定义赋值
const (
	c1 = iota //0
	c2 = 100  //100
	c3        //100
	c4        //100
)

//插队
const (
	d1 = iota //0
	d2 = 100  //100  插队
	d3 = iota //2
	d4        //3
	d5 = iota //4
	d6 = iota //5
	_         //跳过
	d7        //7
)

//多个常量声明在一行
const (
	f1, f2 = iota + 1, iota + 2
	f3, f4 = iota + 1, iota + 2
	f5, f6 = iota + 1, iota + 2
)

//定义数量级
const (
	_  = iota
	KB = 1 << (10 * iota)
	MB = 1 << (10 * iota)
	TB = 1 << (10 * iota)
	PB = 1 << (10 * iota)
)

func main() {
	fmt.Println("n1=", n1)
	fmt.Println("n2=", n2)
	fmt.Println("n3=", n2)
	fmt.Println()

	fmt.Println("a1=", a1)
	fmt.Println("a2=", a2)
	fmt.Println("a3=", a3)
	fmt.Println("a4=", a4)
	fmt.Println()

	fmt.Println("b1=", b1)
	fmt.Println("b2=", b2)
	fmt.Println("b3=", b3)
	fmt.Println()

	fmt.Println("c1=", c1)
	fmt.Println("c2=", c2)
	fmt.Println("c3=", c3)
	fmt.Println("c4=", c4)
	fmt.Println()

	fmt.Println("d1=", d1)
	fmt.Println("d2=", d2)
	fmt.Println("d3=", d3)
	fmt.Println("d4=", d4)
	fmt.Println("d5=", d5)
	fmt.Println("d6=", d6)
	fmt.Println("d7=", d7)
	fmt.Println()

	fmt.Println("f1=", f1)
	fmt.Println("f2=", f2)
	fmt.Println("f3=", f3)
	fmt.Println("f4=", f4)
	fmt.Println("f5=", f5)
	fmt.Println("f6=", f6)
	fmt.Println()

	fmt.Printf("KB=%dB\n", KB)
	fmt.Printf("MB=%dB\n", MB)
	fmt.Printf("TB=%dB\n", TB)
	fmt.Printf("PB=%dB\n", PB)
	fmt.Println()

}
